const webpack = require('webpack')
const os = require('os')

let ip = 'location';
try {
	const network = os.networkInterfaces();
	let networkArr = network['以太网'];
	networkArr && networkArr.forEach((item) => {
		if (item.family === 'IPv4') {
			ip = item.address;
		}
	})
} catch (e) {
	console.log(e);
	ip = 'location';
}
module.exports = {
	productionSourceMap: false,
	outputDir: "dist_cjj_admin", // 输出文件目录
	devServer: {
		port: 8080,
		proxy: {
			// 配置跨域 
			'/api': {
				target: 'https://api.chejj.cn',
				// target: 'http://api.newweb.com',
				changOrigin: true,
				pathRewrite: {
					'^/api': ''
				},
				cookieDomainRewrite: {
					'*': 'localhost',
					// '*': ip
				}
			},
			// 配置跨域 
			'http/geojson': {
				target: 'https://web.chejj.cn',
				changOrigin: true,
				pathRewrite: {
					'^/http/geojson': ''
				},
				cookieDomainRewrite: {
					'*': 'localhost',
					// '*': ip
				}
			},
			// 配置跨域 
			'/http/cluebus': {
				target: 'https://cluebustest.chejj.cn:6061',
				changOrigin: true,
				pathRewrite: {
					'^/http/cluebus': ''
				},
				cookieDomainRewrite: {
					'*': 'localhost',
					// '*': ip
				}
			},
			'/https://i.mycjj.com': {
				target: 'https://i.mycjj.com',
				changOrigin: true,
				pathRewrite: {
					'^/https://i.mycjj.com': ''
				},
				cookieDomainRewrite: {
					'*': 'localhost',
					// '*': ip
				}
			}
		},
	},
	configureWebpack: {
		plugins: [
			new webpack.ProvidePlugin({
				$: "jquery",
				jQuery: "jquery",
				"windows.jQuery": "jquery"
			})
		]
	}
}
